from sqlalchemy.orm import Session

from app.models import VppPrice
from app.schemas.platform import GetDayaheadPlanRequest


def save_vpp_price(session: Session, invitation_id, payload: GetDayaheadPlanRequest):
    """
    保存虚拟电厂价格
    """
    for key, value in payload.vppPrices.items():
        vpp_price = VppPrice(
            invitation_id=invitation_id,
            key=key,
            value=value,
        )
        session.add(vpp_price)
    session.commit()
